﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Admin.master" AutoEventWireup="true" CodeBehind="EmployeeCashAdvance.aspx.cs" Inherits="Legazpi.Payroll.Web.Admin.EmployeeCashAdvance" %>
<asp:Content ID="Content2" ContentPlaceHolderID="headContent" runat="server">    
<script type="text/javascript">
    $(document).ready(function () {
        $('#<%=EmployeeName.ClientID %>').autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: '<%=ResolveUrl("~/Webservices/EmployeeWebService.asmx/FetchEmployees")%>',
                    data: "{ 'employeeName': '" + request.term + "' }",
                    dataType: "json",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    dataFilter: function (data) { return data; },
                    success: function (data) {
                        response($.map(data.d, function (item) {
                            return {
                                label: item.EmployeeName,
                                value: item.EmployeeName,
                                id: item.Id
                            }
                        }))
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert(textStatus);
                    }
                });
            },
            minLength: 2,
            select: function (event, ui) {
                var id = ui.item.id;
                var employeeName = ui.item.label;

                $('#<%=EmployeeName.ClientID %>').val(employeeName);
                $('#<%=EmployeeIdHidden.ClientID %>').val(id);
                $('#<%=SearchBtn.ClientID %>').click();
                //window.location = '<%=Request.Path %>?id=' + id;
            }
        });
    });
</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="leftContent" runat="server">
    <div class="grid_10">                                    
        <%if(IsSuccess) {%>
            <span class="notification n-success"><%=NotifyText %></span>                                                
        <%} %>           
    </div>   
            <div class="grid_3">                                
                <div class="module">
                     <h2><span>New Record Entry</span></h2>
                        
                     <div class="module-body">
                        
                            <p>
                                <label>Employee Name (type in name to search):</label>
                                <asp:TextBox ID="EmployeeName" runat="server" CssClass="input-long"></asp:TextBox>    
                                <asp:HiddenField runat="server" ID="EmployeeIdHidden" Value="0" />   
                                <asp:Button ID="SearchBtn" runat="server" style="display:none"  OnClick="SearchBtn_Click"/>                                                                                         
                            </p>
                            <p>
                                <label>Payroll Date Entry:</label>
                                <asp:DropDownList runat="server" ID="PayrollPeriodDdl" CssClass="input-long" >
                                </asp:DropDownList>                            
                            </p>
                            <p>
                                <label>Cash Advance Type:</label>
                                <asp:DropDownList runat="server" ID="AdvanceDdl" CssClass="input-long" >
                                </asp:DropDownList>                            
                            </p>
                            <p>
                                <label>Amount:</label>
                                <asp:TextBox ID="AmountTxt" runat="server" CssClass="input-long"></asp:TextBox>                                
                                <asp:HiddenField runat="server" ID="EmpAdvIdHidden" Value="0" />                                                            
                            </p>
                            <fieldset>                                
                                <ul>
                                    <li>
                                        <label>                                                                        
                                            <asp:RadioButton GroupName="AdvanceType" runat="server" ID="DebitRado" Checked="true"/>
                                            Debit
                                        </label>
                                    </li>                                    
                                    <li>
                                        <label>                                                                        
                                            <asp:RadioButton GroupName="AdvanceType" runat="server" ID="CreditRado"/>
                                            Credit
                                        </label>
                                    </li>                                    
                                </ul>
                            </fieldset>
                            <fieldset>
                                <asp:Button id="SubmitBtn" runat="server" Text="Submit" CssClass="submit-green" 
                                    onclick="SubmitBtn_Click" />                                                                                                            
                                <asp:Button id="CancelBtn" runat="server" Text="Cancel" CssClass="submit-gray" 
                                    onclick="CancelBtn_Click" />                                                                                                            
                            </fieldset>
                        
                        
                     </div> <!-- End .module-body -->
                </div> <!-- End .module -->
                <div style="clear:both;"></div>
            </div>
            <div class="grid_7">      
   
                    <div class="module">
                         <h2><span>Cash Advances Table</span></h2>
                     
                         <div class="module-body">                                                         
                         <asp:Repeater ID="repeater" runat="server" OnItemCommand="repeater_ItemCommand" onitemdatabound="repeater_ItemDataBound">
                            <HeaderTemplate>
                                <table width="100%" border="0" class="tablesorter">
                                    <thead>
                                        <th>Id</th>                        
                                        <th>Code</th>
                                        <th>Paydate Cover</th>
                                        <th>Debit</th>
                                        <th>Credit</th>
                                        <th>Balance</th>                                        
                                        <th width="15%"></th>
                                    </thead>
                                    <tbody>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <tr class="odd">                                    
                                    <td><%# Eval("Id")%></td>                                        
                                    <td><asp:Literal runat="server" ID="CodeLiteral"></asp:Literal></td>                                    
                                    <td><asp:Literal runat="server" ID="PaydateLiteral"></asp:Literal></td>             
                                    <td><asp:Literal runat="server" ID="DebitLiteral"></asp:Literal></td>     
                                    <td><asp:Literal runat="server" ID="CreditLiteral"></asp:Literal></td>     
                                    <td><asp:Literal runat="server" ID="BalanceLiteral"></asp:Literal></td>                                    
                                    <td>                                        
                                        <asp:ImageButton ID="SaveLinkBtn" runat="server" ImageUrl="/images/pencil.gif" Width="16" Height="16" AlternateText="save" CommandName="update" CommandArgument=<%# Eval("Id")%> />
                                        <asp:ImageButton ID="DeleteLinkBtn" runat="server" ImageUrl="/images/bin.gif" Width="16" Height="16" AlternateText="delete" CommandName="delete"  CommandArgument=<%# Eval("Id")%> OnClientClick="return confirm('Confirm Delete?');" />                                        
                                    </td>
                                </tr>                            
                            </ItemTemplate>
                            <AlternatingItemTemplate>
                                <tr class="even">                                    
                                    <td><%# Eval("Id")%></td>                                        
                                    <td><asp:Literal runat="server" ID="CodeLiteral"></asp:Literal></td>                                    
                                    <td><asp:Literal runat="server" ID="PaydateLiteral"></asp:Literal></td>             
                                    <td><asp:Literal runat="server" ID="DebitLiteral"></asp:Literal></td>     
                                    <td><asp:Literal runat="server" ID="CreditLiteral"></asp:Literal></td>     
                                    <td><asp:Literal runat="server" ID="BalanceLiteral"></asp:Literal></td>                                    
                                    <td>                                        
                                        <asp:ImageButton ID="SaveLinkBtn" runat="server" ImageUrl="/images/pencil.gif" Width="16" Height="16" AlternateText="save" CommandName="update" CommandArgument=<%# Eval("Id")%> />
                                        <asp:ImageButton ID="DeleteLinkBtn" runat="server" ImageUrl="/images/bin.gif" Width="16" Height="16" AlternateText="delete" CommandName="delete"  CommandArgument=<%# Eval("Id")%> OnClientClick="return confirm('Confirm Delete?');" />                                        
                                    </td>
                                </tr>                            
                            </AlternatingItemTemplate>
                            <FooterTemplate>
                                    </tbody>
                                </table>
                            </FooterTemplate>
                         </asp:Repeater>                            
                            <div id="pager" class="pager">                            
                                <div>
                                </div>                            
                            </div>
                            <div class="table-apply">
                                <div>
                                    <span>Total Running Balance: <strong>P <%=RunningBalance.ToString("N")%></strong> </span> 
                                </div>
                            </div>
                            <div style="clear: both"></div>                                                   
                         </div> <!-- End .module-body -->

                    </div>  <!-- End .module -->        		   
                                                            
            </div>
</asp:Content>